#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    srand(time(nullptr));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_accept_clicked()
{
    ui->label->setText("舍友给你嘴一个你快去");
    ui->reject->setEnabled(true);
    ui->reject->setText("恭喜恭喜");
}
void Widget::on_reject_pressed()
{
    static int a = 0;
    a++;
    if(a == 10)
    {
        ui->reject->setText("别挣扎了！！！");
        ui->reject->setEnabled(false);
        return;
    }
    while(1){
        int a = rand() % this->geometry().x();
        int b = rand() % this->geometry().y();
        if(a >= ui->label->geometry().x() - ui->reject->geometry().width() && a < ui->label->geometry().x() + ui->label->geometry().width()
          && b >= ui->label->geometry().y() - ui->reject->geometry().height() && b < ui->label->geometry().y() + ui->label->geometry().height()
          && a >= ui->accept->geometry().x() - ui->reject->geometry().width() && a < ui->accept->geometry().x() + ui->accept->geometry().width()
          && b >= ui->accept->geometry().y() - ui->reject->geometry().height() && b < ui->accept->geometry().y() + ui->accept->geometry().height())
            continue;
        ui->reject->move(a, b);
        break;
    }
}
